package com.wat.service.Impl;

import com.wat.domain.Order;
import com.wat.service.OrderService;
import com.wat.service.UserService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

@Service
public class OrderServiceImpl implements OrderService, InitializingBean {

	@Autowired
	private UserServiceImpl userServiceImpl;

	public OrderServiceImpl(){
		System.out.println("-------- OrderServiceImpl (普通类)构造方法 --------------");
	}

	@Override
	public void afterPropertiesSet() {
		System.out.println("-------- OrderServiceImpl (普通类) afterPropertiesSet() --------------");
	}

	@PostConstruct
	public void lifecycleInit(){
		System.out.println("-------- OrderServiceImpl (普通类) @PostConstruct init-method() --------------");
	}


	public void setUserServiceImpl(UserServiceImpl userServiceImpl){
		System.out.println("-------- OrderServiceImpl (普通类)初始化 --------------");
		this.userServiceImpl = userServiceImpl;
	}

	private static Order order = null;

	@Override
	public Order createOrder(String username, String product) {
		order = new Order();
		order.setUsername(username);
		order.setProduct(product);
		return order;
	}

	@Override
	public Order queryOrder(String username) {
		return order;
	}

	@Override
	public String toString() {
		return "OrderServiceImpl{" +
				"userServiceImpl=" + userServiceImpl +
				'}';
	}
}
